package com.hejia.alauda.entity;

import javax.persistence.Column;

import org.codehaus.jackson.annotate.JsonIgnoreProperties;

import com.hejia.alauda.Constants;

/**
 * 
 * 支付网关支持银行实体
 *
 *
 * Created by showone on 2015 下午4:05:53.
 *
 * @Copyright: 2015 www.hejiajinrong.com All rights reserved.
 */
@JsonIgnoreProperties(value = { "createDate", "modifyDate", "payGate",
		"payBankCode" })
public class PayGateBank extends BaseEntity {
	private static final long serialVersionUID = 1L;

	@Column(length = 50)
	private String bankName;// 银行名称

	@Column(length = 50)
	private String bankCode;// 银行编码

	@Column(length = 50)
	private String payBankCode;// 银行网关编码

	@Column(length = 10)
	private Long singleLimit;// 单笔限额,Null不限制

	@Column(length = 10)
	private Long dayLimit;// 单日限额,Null不限制

	@Column(length = 10)
	private Long monthLimit;// 单月限额,Null不限制

	@Column
	private Boolean webEnable;// 支持web

	@Column
	private Boolean h5Enable;// 支持h5

	@Column
	private Boolean iOSEnable;// 支持iOS

	@Column
	private Boolean androidEnable;// 支持android

	@Column
	private Boolean inuse;// 使用中
	
	private Boolean stable;//是否稳定

	@Column
	private Long paygateid;// 支付网关ID

	public String getBankName() {
		return bankName;
	}

	public void setBankName(String bankName) {
		this.bankName = bankName;
	}

	public String getBankCode() {
		return bankCode;
	}

	public void setBankCode(String bankCode) {
		this.bankCode = bankCode;
	}

	public Long getSingleLimit() {
		return singleLimit;
	}

	public void setSingleLimit(Long singleLimit) {
		this.singleLimit = singleLimit;
	}

	public Long getDayLimit() {
		return dayLimit;
	}

	public void setDayLimit(Long dayLimit) {
		this.dayLimit = dayLimit;
	}

	public Long getMonthLimit() {
		return monthLimit;
	}

	public void setMonthLimit(Long monthLimit) {
		this.monthLimit = monthLimit;
	}

	public Boolean getWebEnable() {
		return webEnable;
	}

	public void setWebEnable(Boolean webEnable) {
		this.webEnable = webEnable;
	}

	public Boolean getH5Enable() {
		return h5Enable;
	}

	public void setH5Enable(Boolean h5Enable) {
		this.h5Enable = h5Enable;
	}

	public Boolean getiOSEnable() {
		return iOSEnable;
	}

	public void setiOSEnable(Boolean iOSEnable) {
		this.iOSEnable = iOSEnable;
	}

	public Boolean getAndroidEnable() {
		return androidEnable;
	}

	public void setAndroidEnable(Boolean androidEnable) {
		this.androidEnable = androidEnable;
	}

	public Boolean getInuse() {
		return inuse;
	}

	public void setInuse(Boolean inuse) {
		this.inuse = inuse;
	}

	public Long getPaygateid() {
		return paygateid;
	}

	public void setPaygateid(Long paygateid) {
		this.paygateid = paygateid;
	}

	public String getPayBankCode() {
		return payBankCode;
	}

	public void setPayBankCode(String payBankCode) {
		this.payBankCode = payBankCode;
	}

	public boolean isUseable(String os) {
		if (Constants.PLATFORM_IOS.equalsIgnoreCase(os)) {
			return iOSEnable.booleanValue();
		} else if (Constants.PLATFORM_ANDORID.equalsIgnoreCase(os)) {
			return androidEnable.booleanValue();
		} else if (Constants.PLATFORM_H5.equalsIgnoreCase(os)) {
			return h5Enable.booleanValue();
		} else {
			return webEnable.booleanValue();
		}
	}

	public Boolean getStable() {
		return stable;
	}

	public void setStable(Boolean stable) {
		this.stable = stable;
	}
	
	public String getMaxInfo() {
		StringBuffer maxInfo = new StringBuffer();
		maxInfo.append("限额：单笔" + limit(singleLimit));
		maxInfo.append("，单日" + limit(dayLimit));
		maxInfo.append("，单月" + limit(monthLimit));
		return maxInfo.toString();
	}

	/**
	 * 支付限额信息处理
	 * 
	 * @param amount
	 * @return
	 */
	private String limit(Long amount) {
		if (amount == null || amount.longValue() == 0) {
			return "不限";
		}
		if (amount.longValue() >= 10000) {
			return amount.longValue() / 10000 + "万元";
		}
		return amount.longValue() + "元";
	}
}
